#include <iostream>
#include <unistd.h>
using namespace std;

class Weapon;
class Hero{
private:
	int hp;//生命值
	int atk;//攻击力
	int def;//防御力
	int spd;//速度
public:
	Hero(int hp=100,int atk=5,int def=5,int spd=5):hp(hp),atk(atk),def(def),spd(spd){}
	void add_hp(int hp){this->hp+=hp;}
	void add_atk(int atk){this->atk+=atk;}
	void add_def(int def){this->def+=def;}
	void add_spd(int spd){this->spd+=spd;}
	int get_hp(){return hp;}
	int get_atk(){return atk;}
	int get_def(){return def;}
	int gget_spd(){return spd;}
	void equipWeapon(Weapon*W);
	void show(){
		cout << "hp=" << hp << endl;
		cout << "atk=" << atk << endl;
		cout << "def=" << def << endl;
		cout << "spd=" << spd << endl;
	}
};
class Weapon{
private:
	int atk;
public:
	Weapon(int atk=1):atk(atk){}
	int getatk(){return atk;}
	virtual void add(Hero&Hero){}
};
class sword:public Weapon{
private:
	int hp;
public:
	sword(int atk=1,int hp=1):hp(hp),Weapon(atk){}
	void add(Hero&Hero){
		//int aatk=Hero.get_atk()+this->getatk();
		//int hhp=Hero.get_hp()+this->hp;
		Hero.add_atk(this->getatk()*-1);
		Hero.add_hp(this->hp*-1);
	}
};
void Hero::equipWeapon(Weapon*W){
	W->add(*this);
}
int main()
{
	sword aa;
	Hero NN;
	NN.show();
	while(1){
	NN.equipWeapon(&aa);
	NN.show();
	sleep(1);
	}

	return 0;
}
